package cn.wolfcode.rocketmq.boot;

import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;


@Component
@RocketMQMessageListener(
        topic = "01-boot-hello",
        consumerGroup = "wolfcode-consumer",
        messageModel = MessageModel.CLUSTERING,
        selectorType = SelectorType.TAG,
        selectorExpression = "age > 16"
)
public class HelloConsumer implements RocketMQListener<MessageExt> {
    @Override
    public void onMessage(MessageExt messageExt) {
        System.out.println(888);
        messageExt.getUserProperty("age");
        System.out.println(messageExt.getUserProperty("age"));
        System.out.println(messageExt.getProperties().keySet());
        System.out.println(messageExt.getProperties().containsKey("name"));
        messageExt.getUserProperty("name");
        messageExt.getUserProperty("USERS_name");
        System.out.println("接收到的消息:"+new String(messageExt.getBody()));
    }
}
